Slightly sped up DOM rendering when switching monitors on Watch page#4884
Slightly sped up DOM rendering when switching monitors on Watch page#4884IgorA100 wants to merge 1 commit into
Conversation
Clearing via textContent is performed without page parsing, which speeds up cleanup. When executing innerHTML, clearing will first occur by parsing the page, and then assigning new elements. This will slightly speed up DOM rendering by quickly clearing.
There was a problem hiding this comment.
Pull request overview
This PR aims to speed up UI updates on the Watch page when switching monitors by clearing the main monitor container before injecting new stream markup.
Changes:
- Clears the
#monitorelement viatextContent = ''before settinginnerHTMLto the new monitor’sstreamHTML.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| //Change main monitor block | ||
| monitor_div.textContent = ''; | ||
| monitor_div.innerHTML = currentMonitor.streamHTML; |
|
copilot doesn't like your change. I'm not sure. I'm a little surprised that that would give any noticeable speed increase. Would be nice if we could just say turn off dom updates until we are ready to redraw.... maybe there is a way. I just don't know it. github has gotten stupid about copilot billing. I'm going to integrate my paid Claude subscription instead. |
I don't yet know what criteria to use to determine whether we're ready for a repaint.
I once tested the speed of clearing using
Heh.... |
Clearing via
textContentis performed without page parsing, which speeds up cleanup.When executing
innerHTML, clearing will first occur by parsing the page, and then assigning new elements.This will slightly speed up DOM rendering by quickly clearing.